package com.motion.controller;

import com.motion.generator.entity.UserSignInDay;
import com.motion.result.Result;
import com.motion.result.ResultFactory;
import com.motion.service.UserSignInDayService;
import com.motion.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/api/useryund")
@Api("用户数据")
public class UserDataController {
    @Autowired
    private UserService userService;
    @Autowired
    private UserSignInDayService userLoginService;

    //获取运动中心训练日记
    //无法使用，但在usercontroller中可以使用
    @RequestMapping(value = "/getVerificationCode", method = RequestMethod.GET)
    public Result getSignInDayList(@RequestParam String token){
        //Long userId=Long.valueOf(String.valueOf(StpUtil.getLoginIdByToken(token)));
        Long userId=Long.valueOf(token);
        List<UserSignInDay> result=userLoginService.getSignInDay(userId);
        return ResultFactory.buildSuccessResult(result);
    }
}
